package com.jubao.ejb.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 
 * @author conan
 * 
 * http://docs.jboss.org/ejb3/app-server/tutorial/clusteredentity/clusteredentity.html
 * This defines that Category should be cached. Any attempt to look up Category
 * by its primary key, will first attempt to read the entry from the cache. If
 * it cannot be found it will load it up from the database.
 * 
 * http://technology.amis.nl/blog/?p=1363 EJB 3.0 Java Persistence API - refresh
 * After Insert: Using EntityListeners to absorb the effects from Database
 * Triggers by Lucas Jellema
 */
@Entity
@Table(name = "category_tbl", schema = "jubao_database", uniqueConstraints = {})
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class Category extends GeneEntity implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4553483823098511037L;

	@Column(nullable = false, unique = true, updatable = false)
	private String id; // manual defined unique id for the category

	private String name;

	private String fullName;

	private String smallImage;

	@ManyToOne
	Category primaryParent;

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the fullName
	 */
	public String getFullName() {
		return fullName;
	}

	/**
	 * @param fullName the fullName to set
	 */
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	/**
	 * @return the smallImage
	 */
	public String getSmallImage() {
		return smallImage;
	}

	/**
	 * @param smallImage the smallImage to set
	 */
	public void setSmallImage(String smallImage) {
		this.smallImage = smallImage;
	}

	/**
	 * @return the primaryParent
	 */
	public Category getPrimaryParent() {
		return primaryParent;
	}

	/**
	 * @param primaryParent the primaryParent to set
	 */
	public void setPrimaryParent(Category primaryParent) {
		this.primaryParent = primaryParent;
	}

}
